﻿namespace PowerSong.Projection
    {
    using System;
    using System.Windows;
    using System.Windows.Input;

    /// <summary>
    /// Interaction logic for ProjectorWindow.xaml
    /// </summary>
    public partial class ProjectorWindow : Window
        {

        private bool fullScreen = false;

        private ProjectorSet projectorSet = null;

        public Projector Projector { get; private set; }

        public ProjectorWindow(ProjectorSet projectorSet)
            {
            InitializeComponent();
            this.projectorSet = projectorSet;
            this.Projector = new Projector(this.LayoutRoot, this);
            }

        private void Window_MouseDoubleClick(object sender, MouseButtonEventArgs e)
            {
            if (fullScreen)
                {
                ResizeToWindow();
                }
            else
                {
                ResizeToFullScreen();
                }
            }

        public void ResizeToWindow()
            {
            this.WindowStyle = WindowStyle.ToolWindow;
            this.WindowState = WindowState.Normal;
            this.ResizeMode = ResizeMode.CanResize;
            fullScreen = false;
            }

        public void ResizeToFullScreen()
            {
            this.WindowStyle = WindowStyle.None;
            this.WindowState = WindowState.Maximized;
            this.ResizeMode = ResizeMode.NoResize;
            fullScreen = true;
            }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
            {
            Projector.Clear();
            projectorSet.RemoveProjectorInternal(Projector, true);
            }

        }

    }
